"""
使用生成器 生成杨辉三角
"""


def triangles(n):
    row = [1]
    i = 0
    while i < n:
        yield row
        row = [1] + [row[k] + row[k + 1] for k in range(len(row) - 1)] + [1]
        i += 1


for item in triangles(4):
    print(item)
